package com.ruoyi.server.api.wxlogin.mapper;

import com.ruoyi.server.api.wxlogin.entiy.WxUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.security.core.userdetails.User;

/**
 * @Description TODO 小程序微信授权登录
 * @ClassName UserLoginMapper
 * @Author HH
 * @Date 2023/4/3 18:25
 **/
@Mapper
public interface WxLoginMapper {



    /**
    * @Description 根据电话号查询用户信息
    * @Author HH
    * @Date 2023/4/12 14:11
    * @Return com.zhuiyun.project.api.appuser.entiy.User;
    * @param phone
    */
    @Select("<script>SELECT id,nick_name,password,phone,avatar_url,openid,create_time,update_time FROM user WHERE phone = #{phone}</script>")
    User getUserInfoByPhone(String phone);


    /**
    * @Description 根据电话号查询用户信息
    * @Author HH
    * @Date 2023/4/12 14:11
    * @Return com.zhuiYun.project.api.login.entity.User
    * @param user
    */
    @Update("<script>UPDATE user SET openid = #{openid} WHERE phone = #{phone}</script>")
    int updateUserByPhone(User user);


}
